package org.example.Filter;


import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;


import java.io.IOException;
@Slf4j
//@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {
    @Override//初始化方法web启动 只时执行一次
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("init 方法初始化");
    }
    //拦截到请求后执行 ，会执行多次
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("doFilter 方法执行--------");
        //放行
        filterChain.doFilter(servletRequest,servletResponse);

    }
    @Override//销毁方法web关闭时执行一次
    public void destroy() {
        log.info("destroy 方法销毁");

    }
}

